package edu.gduf.decortor;

/**
 * Created by Zhang DaoChuan on 2017/2/18.
 */
public abstract class Duck {
    protected FlyBehavior flyBehavior;
    protected QuackBehavior quackBehavior;

    public Duck(){
        display();
    }

    public abstract void display();

    public void performSwim(){
        System.out.println("All ducks float,even decoys");
    }

    public void performQuack(){
        quackBehavior.quack();
    }

    public void performFly(){
        flyBehavior.fly();
    }
//    动态设定行为
    public void setFlyBehavior(FlyBehavior flyBehavior){
        this.flyBehavior = flyBehavior;
    }
//    动态设定行为
    public void setQuackBehavior(QuackBehavior quackBehavior){
        this.quackBehavior = quackBehavior;
    }

}
